CentOS 5
Sponsored Link

CommandModule
  Basic usage of CommandModule. It's possible to do most operations with this module.

func target call command run "command"
[1] Run 'yum update' on all minion
[root@certmaster ~]#
func "*" call command run "yum -y update" | sed 's/\\n/\n/g'

('www.server-linux.info',
[0,
  'Loaded plugins: fastestmirror
Loading mirror speeds from cached hostfile
* addons: ftp.iij.ad.jp
* base: ftp.iij.ad.jp
* extras: ftp.iij.ad.jp
* updates: ftp.iij.ad.jp
Setting up Update Process
No Packages marked for Update
',
''])
('minion.server-linux.info',
[0,
  'Loaded plugins: fastestmirror
Loading mirror speeds from cached hostfile
* addons: rsync.atworks.co.jp
* base: rsync.atworks.co.jp
* extras: rsync.atworks.co.jp
* updates: rsync.atworks.co.jp
Setting up Update Process
No Packages marked for Update
',
''])
[2] Execute 'ls /root' on all minion
[root@certmaster ~]#
func "*" call command run "ls /root" | sed 's/\\n/\n/g'

('minion.server-linux.info',
[0,
'anaconda-ks.cfg
install.log
install.log.syslog
install.sh
Maildir
',
''])
('www.server-linux.info',
[0,
'anaconda-ks.cfg
install.log
install.log.syslog
mbox
',
''])
[3] Execute 'cat /etc/passwd' on a minion
[root@certmaster ~]#
func "www.server-linux.info" call command run "cat /etc/passwd" | sed 's/\\n/\n/g'

('www.server-linux.info',
[0,
'root:x:0:0:root:/root:/bin/bash
bin:x:1:1:bin:/bin:/sbin/nologin
daemon:x:2:2:daemon:/sbin:/sbin/nologin
adm:x:3:4:adm:/var/adm:/sbin/nologin
lp:x:4:7:lp:/var/spool/lpd:/sbin/nologin
sync:x:5:0:sync:/sbin:/bin/sync
shutdown:x:6:0:shutdown:/sbin:/sbin/shutdown
halt:x:7:0:halt:/sbin:/sbin/halt
mail:x:8:12:mail:/var/spool/mail:/sbin/nologin
news:x:9:13:news:/etc/news:
uucp:x:10:14:uucp:/var/spool/uucp:/sbin/nologin
operator:x:11:0:operator:/root:/sbin/nologin
games:x:12:100:games:/usr/games:/sbin/nologin
gopher:x:13:30:gopher:/var/gopher:/sbin/nologin
ftp:x:14:50:FTP User:/var/ftp:/sbin/nologin
nobody:x:99:99:Nobody:/:/sbin/nologin
nscd:x:28:28:NSCD Daemon:/:/sbin/nologin
vcsa:x:69:69:virtual console memory owner:/dev:/sbin/nologin
pcap:x:77:77::/var/arpwatch:/sbin/nologin
rpc:x:32:32:Portmapper RPC user:/:/sbin/nologin
mailnull:x:47:47::/var/spool/mqueue:/sbin/nologin
smmsp:x:51:51::/var/spool/mqueue:/sbin/nologin
oprofile:x:16:16:Special user account to be used by OProfile:/home/oprofile:/sbin/nologin
xfs:x:43:43:X Font Server:/etc/X11/fs:/sbin/nologin
sshd:x:74:74:Privilege-separated SSH:/var/empty/sshd:/sbin/nologin
rpcuser:x:29:29:RPC Service User:/var/lib/nfs:/sbin/nologin
nfsnobody:x:4294967294:4294967294:Anonymous NFS User:/var/lib/nfs:/sbin/nologin
dbus:x:81:81:System message bus:/:/sbin/nologin
avahi:x:70:70:Avahi daemon:/:/sbin/nologin
haldaemon:x:68:68:HAL daemon:/:/sbin/nologin
avahi-autoipd:x:100:104:avahi-autoipd:/var/lib/avahi-autoipd:/sbin/nologin
ntp:x:38:38::/etc/ntp:/sbin/nologin
apache:x:48:48:Apache:/var/www:/sbin/nologin
distcache:x:94:94:Distcache:/:/sbin/nologin
hirokun:x:500:500::/home/hirokun:/bin/bash
tomcat:x:501:501::/usr/tomcat6:/sbin/nologin
nagios:x:101:105:nagios:/var/log/nagios:/bin/sh
postfix:x:89:89::/var/spool/postfix:/sbin/nologin
',
''])
[4] Execute 'touch /root/test.txt' on all minion
[root@certmaster ~]#
func "*" call command run "touch /root/test.txt"

('minion.server-linux.info', [0, '', ''])
('www.server-linux.info', [0, '', ''])
[root@certmaster ~]#
func "*" call command run "ls /root" | sed 's/\\n/\n/g'

('minion.server-linux.info',
[0,
'anaconda-ks.cfg
install.log
install.log.syslog
install.sh
Maildir
test.txt
# just created

',
''])
('www.server-linux.info',
[0,
'anaconda-ks.cfg
install.log
install.log.syslog
mbox
test.txt
# just created

',
''])
[5] Execute 'chown nobody. /root/test.txt;chmod 600 /root/test.txt' on all minion
[root@certmaster ~]#
func "*" call command run "chown nobody. /root/test.txt;chmod 600 /root/test.txt"

('minion.server-linux.info', [0, '', ''])
('www.server-linux.info', [0, '', ''])
[root@certmaster ~]#
func "*" call command run "ls -l /root/test.txt" | sed 's/\\n/\n/g'

('minion.server-linux.info',
[0, '-rw------- 1 nobody nobody 0 Nov 29 03:02 /root/test.txt
', ''])
('www.server-linux.info',
[0, '-rw------- 1 nobody nobody 0 Nov 29 03:02 /root/test.txt
', ''])
[6] Restart ntpd on all minion
[root@certmaster ~]#
func "*" call command run "service ntpd restart" | sed 's/\\n/\n/g'

('minion.server-linux.info',
[0, 'Shutting down ntpd:
[ OK ]

Starting ntpd:
[ OK ]

', ''])
('www.server-linux.info',
[0, 'Shutting down ntpd:
[ OK ]

Starting ntpd:
[ OK ]

', ''])
 
Tweet